/*********************************************************************
	Rhapsody	: 7.5.2
	Login		: dan
	Component	: Test
	Configuration 	: DefaultConfig
	Model Element	: TCon_RobotController
//!	Generated Date	: Sat, 18, Dec 2010 
	File Path	: Test/DefaultConfig/TPkg_RobotController/TCon_RobotController.java
*********************************************************************/

package TPkg_RobotController;

//## dependency RobotPkg 
import RobotPkg.*;
//## classInstance itsRobotController 
import RobotPkg.RobotController;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.*;
//## auto_generated
import org.btc.TestConductor.TestConductor;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.states.*;

//----------------------------------------------------------------------------
// TPkg_RobotController/TCon_RobotController.java                                                                  
//----------------------------------------------------------------------------

//## package TPkg_RobotController 


//## class TCon_RobotController 
public class TCon_RobotController implements RiJStateConcept {
    
    public Reactive reactive;		//## ignore 
    
    protected  int testcase_terminated;		//## attribute testcase_terminated 
    
    protected DummyDriver_of_RobotController itsDummyDriver_of_RobotController;		//## classInstance itsDummyDriver_of_RobotController 
    
    protected RobotController itsRobotController;		//## classInstance itsRobotController 
    
    
    //## statechart_method 
    public RiJThread getThread() {
        return reactive.getThread();
    }
    
    //## statechart_method 
    public void schedTimeout(long delay, long tmID, RiJStateReactive reactive) {
        getThread().schedTimeout(delay, tmID, reactive);
    }
    
    //## statechart_method 
    public void unschedTimeout(long tmID, RiJStateReactive reactive) {
        getThread().unschedTimeout(tmID, reactive);
    }
    
    //## statechart_method 
    public RiJEventConsumer getEventConsumer() {
        return (RiJEventConsumer)reactive;
    }
    
    //## statechart_method 
    public void gen(RiJEvent event) {
        reactive._gen(event);
    }
    
    //## statechart_method 
    public void queueEvent(RiJEvent event) {
        reactive.queueEvent(event);
    }
    
    //## statechart_method 
    public int takeEvent(RiJEvent event) {
        return reactive.takeEvent(event);
    }
    
    // Constructors
    
    //## auto_generated 
    public  TCon_RobotController(RiJThread p_thread) {
        reactive = new Reactive(p_thread);
        initRelations(p_thread);
    }
    
    //## operation Code_tc_0() 
    public synchronized void Code_tc_0() {
        //#[ operation Code_tc_0() 
        itsRobotController.gen(new evOnOff());
        
        try {  
          wait(1000);
           TestConductor.ASSERT_NAME("Robot on",itsRobotController.isIn(Sensor.on));   
            for(int i=0; i<6; i++) {
          		Sensor sensor = itsRobotController.getSensor(i);
          		TestConductor.ASSERT_NAME("Sensor initial value",sensor.getLine() == false);
           		sensor.gen(new lineSeen());
           		wait(200);
          		TestConductor.ASSERT_NAME("Sensor state change", sensor.getLine() == true);
          	}
          	itsRobotController.gen(new evOnOff()); 
        } catch(Exception e) 
        { e.printStackTrace();}  
        
        
        
        //#]
    }
    
    //## operation SC_tc_0() 
    public void SC_tc_0() {
        //#[ operation SC_tc_0() 
        testcase_terminated = 0;
        TCSC_tc_0 tc = new TCSC_tc_0(this,itsRobotController,RiJMainThread.instance());
        tc.startBehavior();
        
        //#]
    }
    
    //## operation rtc_TCSC_tc_0(TCSC_tc_0) 
    public void rtc_TCSC_tc_0(final TCSC_tc_0 p1) {
        //#[ operation rtc_TCSC_tc_0(TCSC_tc_0) 
        //#]
    }
    
    //## operation rtc_exit() 
    public void rtc_exit() {
        //#[ operation rtc_exit() 
        // The following code is auto generated by TestConductor
        //////////////////////////////////////////////////////////////
        
        //#]
    }
    
    //## operation rtc_init() 
    public void rtc_init() {
        //#[ operation rtc_init() 
        // The following code is auto generated by TestConductor
        //////////////////////////////////////////////////////////////
        
        //#]
    }
    
    //## auto_generated 
    public  int getTestcase_terminated() {
        return testcase_terminated;
    }
    
    //## auto_generated 
    public void setTestcase_terminated( int p_testcase_terminated) {
        testcase_terminated = p_testcase_terminated;
    }
    
    //## auto_generated 
    public DummyDriver_of_RobotController getItsDummyDriver_of_RobotController() {
        return itsDummyDriver_of_RobotController;
    }
    
    //## auto_generated 
    public DummyDriver_of_RobotController newItsDummyDriver_of_RobotController() {
        itsDummyDriver_of_RobotController = new DummyDriver_of_RobotController();
        return itsDummyDriver_of_RobotController;
    }
    
    //## auto_generated 
    public void deleteItsDummyDriver_of_RobotController() {
        itsDummyDriver_of_RobotController=null;
    }
    
    //## auto_generated 
    public RobotController getItsRobotController() {
        return itsRobotController;
    }
    
    //## auto_generated 
    public RobotController newItsRobotController(RiJThread p_thread) {
        itsRobotController = new RobotController(p_thread);
        return itsRobotController;
    }
    
    //## auto_generated 
    public void deleteItsRobotController() {
        itsRobotController=null;
    }
    
    //## auto_generated 
    protected void initRelations(RiJThread p_thread) {
        itsDummyDriver_of_RobotController = newItsDummyDriver_of_RobotController();
        itsRobotController = newItsRobotController(p_thread);
        itsDummyDriver_of_RobotController.setItsRobotController(itsRobotController);
    }
    
    //## auto_generated 
    public boolean startBehavior() {
        boolean done = true;
        done &= itsRobotController.startBehavior();
        done &= reactive.startBehavior();
        return done;
    }
    
    //## ignore 
    public class Reactive extends RiJStateReactive {
        
        // Default constructor 
        public Reactive() {
            this(RiJMainThread.instance());
        }
        
        
        // Constructors
        
        public  Reactive(RiJThread p_thread) {
            super(p_thread);
        }
        
    }
}
/*********************************************************************
	File Path	: Test/DefaultConfig/TPkg_RobotController/TCon_RobotController.java
*********************************************************************/

